package com.kkb.service;
import com.kkb.mapper.AdminsMapper;
import com.kkb.pojo.Admins;
import com.kkb.pojo.AdminsExample;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class LoginService {
    @Resource
    private AdminsMapper adminsMapper;
    /**
     * 查找用户是否存在
     * @param admins
     * @return
     */
    public Admins login(Admins admins){
        //从数据库中查询，如果存在则则返回对象，不存在就返回null
        AdminsExample admin = new AdminsExample();
        AdminsExample.Criteria criteria = admin.createCriteria();
        criteria.andLoginNameEqualTo(admins.getLoginName().trim());
        criteria.andAdminPwdEqualTo(admins.getAdminPwd().trim());
        List<Admins> admins1 = adminsMapper.selectByExample(admin);
        for (Admins a:admins1){
            if (a!=null){
                return a;
            }
        }
        return null;
    }


}
